<?php

namespace App\Admin\Controllers;

use App\ip;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class IpController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\onlineip';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new ip());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('ip', 'ip');

        });

        $grid->column('ip', __('IP'));
        $grid->column('Date', __('购买日期'));
        $grid->column('Source', __('购买来源'));
        $grid->column('Platgrid', __('应用平台'));
        $grid->column('Shop', __('应用店铺'));
        $grid->column('Status', __('状态'));


        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(ip::findOrFail($id));


        $show->field('ip', __('IP'));
        $show->field('Date', __('购买日期'));
        $show->field('Source', __('购买来源'));
        $show->field('Platform', __('应用平台'));
        $show->field('Shop', __('应用店铺'));
        $show->field('Status', __('状态'));


        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new ip());


        $form->ip('ip', __('IP'));
        $form->datetime('Date', __('购买日期'));
        $form->text('Source', __('购买来源'));
        $form->text('Platform', __('应用平台'));
        $form->text('Shop', __('应用店铺'));
        $form->text('Status', __('状态'));


        return $form;
    }
}
